
/* STANDARD INCLUDE FILES */
{mfdeclre.i} /* INCLUDE FILE SHARED VARIABLES */
{cxcustom.i "POPOMTD.P"}
{gplabel.i}  /* EXTERNAL LABEL INCLUDE */
{pxmaint.i}  /* STANDARD MAINTENANCE COMPONENT INCLUDE FILE */

/* NEW SHARED VARIABLES */
define new shared variable subtype  as character format "x(12)" no-undo.
define new shared variable workord  like wo_nbr.
define new shared variable worklot  like wo_lot.
define new shared variable routeop  like wr_op.
define new shared variable workpart like wo_part.
define new shared variable workproj like wo_project.

/* SHARED VARIABLES */
define shared variable rndmthd like rnd_rnd_mthd.
define shared variable desc1   like pt_desc1.
define shared variable desc2   like pt_desc2.
define shared variable line    like sod_line.
define shared variable po_recno as recid.
define shared variable vd_recno as recid.
define shared variable ext_cost like pod_pur_cost.
define shared variable line_opened    as logical.
define shared variable old_pod_status like pod_status.
define shared variable old_type like pod_type.
define shared variable pod_recno as recid.
define shared variable podcmmts       like mfc_logical.
define shared variable st_qty like pod_qty_ord.
define shared variable st_um like pod_um.
define shared variable clines as integer.
define shared variable blanket as logical.
define shared variable sngl_ln like poc_ln_fmt.
define shared variable old_pod_site like pod_site.
define shared variable continue as logical.

/* SHARED FRAME(S) */
define shared frame d.

/* LOCAL VARIABLES */
define variable err-flag        as integer.
define variable mfgr            like vp_mfgr.
define variable mfgr_part       like vp_mfgr_part.
define variable old_um_conv     like pod_um_conv.
define variable old_pur_cost    like pod_pur_cost.
define variable old_vpart       like pod_vpart.
define variable old_db          like si_db.
define variable yn              like mfc_logical initial no.
define variable dummy_um        like pt_um no-undo.
define variable pod-project     like pod_project no-undo.
define variable prm-project     like mfc_logical no-undo.
define variable pod-type        like pod_type    no-undo.
define variable prm-enabled     like mfc_logical initial yes no-undo.
define variable old_fix_pr      like pod_fix_pr  no-undo.
define variable old_ers_opt     like pod_ers_opt no-undo.
define variable using_grs       like mfc_logical no-undo.

/* VARIABLES requm AND ok ARE USED BY PROCEDURE        */
/* updateRequisitionCrossReference AS OUTPUT PARAMETER */
define variable requm           as   character   no-undo.
define variable ok              as   logical     no-undo.

/*fdn*/ define shared variable new_pod_status like pod_status.

/*COMMON API CONSTANTS AND VARIABLES*/
{mfaimfg.i}

/*PURCHASE ORDER API TEMP-TABLE, NAMED USING THE "api" PREFIX*/
{popoit01.i}

{pocnvars.i} /* Variables for coinsignment inventory */
{pocnpo.i}  /* Procedures and frames for consignment inventory */

using_grs = can-find(mfc_ctrl where mfc_field   = "grs_installed" and mfc_logical = yes).

/* DETERMINE IF SUPPLIER CONSIGNMENT IS ACTIVE */
{gprun.i ""gpmfc01.p""
    "(input ENABLE_SUPPLIER_CONSIGNMENT,
    input 11,
    input ADG,
    input SUPPLIER_CONSIGN_CTRL_TABLE,
    output using_supplier_consignment)"}

if global-beam-me-up then undo, leave.

if c-application-mode = "API" then do on error undo, return:

    /*GET HANDLE OF API CONTROLLER*/
    {gprun.i ""gpaigh.p"" "(output ApiMethodHandle,
        output ApiProgramName,
        output ApiMethodName,
        output apiContextString)"}
    
    if global-beam-me-up then undo, leave.
    
    /*GET LOCAL PURCHASE ORDER DET TEMP-TABLE*/
    create ttPurchaseOrderDet.
    run getPurchaseOrderDetRecord in ApiMethodHandle (buffer ttPurchaseOrderDet).

end.  /* If c-application-mode = "API" */

/* TAX ENVIRONMENT FORM */
FORM /*GUI*/ 

    RECT-FRAME       AT ROW 1 COLUMN 1.25
    RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
    SKIP(.1)  /*GUI*/
    pod_tax_usage colon 25
    pod_tax_env   colon 25  space(2)
    pod_taxc      colon 25
    pod_taxable   colon 25
    pod_tax_in    colon 25
    SKIP(.4)  /*GUI*/
with frame set_tax row 13 overlay centered side-labels attr-space NO-BOX THREE-D /*GUI*/.

DEFINE VARIABLE F-set_tax-title AS CHARACTER INITIAL "".
RECT-FRAME-LABEL:SCREEN-VALUE in frame set_tax = F-set_tax-title.
RECT-FRAME-LABEL:HIDDEN in frame set_tax = yes.
RECT-FRAME:HEIGHT-PIXELS in frame set_tax = FRAME set_tax:HEIGHT-PIXELS - RECT-FRAME:Y in frame set_tax - 2.
RECT-FRAME:WIDTH-CHARS IN FRAME set_tax = FRAME set_tax:WIDTH-CHARS - .5.  /*GUI*/

/* SET EXTERNAL LABELS */
setFrameLabels(frame set_tax:handle).

/* Defines frames c and d */
{mfpomtb.i}
{&POPOMTD-P-TAG1}

/* ****************************** Main Block ******************************** */

/* CHECK IF PRM IS INSTALLED */
prm-enabled = {pxfunct.i &FUNCTION='isPrmEnabled' &PROGRAM='pjprmxr.p'}.

for first poc_ctrl fields(poc_insp_loc poc_ers_proc) no-lock:
end.

/* GET P.O. HEADER RECORD */
for first po_mstr where recid(po_mstr) = po_recno:
end.

for first vd_mstr fields(vd_addr) where recid(vd_mstr) = vd_recno no-lock:
end.

/* GET P.O. LINE RECORD */
for first pod_det where recid(pod_det) = pod_recno:
end.

/* READS SITE MASTER */
{pxrun.i &PROC='processRead' &PROGRAM='icsixr.p'
    &PARAM="(input  pod_site,
    buffer si_mstr,
    input  false,
    input  false)"
    &NOERROR=true
    &CATCHERROR=true}

/* UPDATES PO LINE LOT RECEIPT FLAG */
if pod_lot_rcpt = no then do:
    {pxrun.i &PROC='getSingleLotReceipt' &PROGRAM='popoxr1.p'
    &PARAM="(input pod_part,
    output pod_lot_rcpt)"
    &NOAPPERROR=true
    &CATCHERROR=true}
end. /* IF pod_lot_rcpt = no */

/* SET THE FLAG TO NO */
continue = no.

/* CALCULATED PO LINE EXTENDED COST */
{pxrun.i &PROC='getPOLineExtendedCost' &PROGRAM='popoxr1.p'
    &PARAM="(input pod_nbr,
    input pod_line,
    input rndmthd,
    output ext_cost)"
    &NOAPPERROR=true
    &CATCHERROR=true}

old_um_conv = pod_um_conv.

/* GETS MANUFACTURER AND MANUFACTURER ITEM FOR A SUPPLIER ITEM */
{pxrun.i &PROC='getManufacturerItemData' &PROGRAM='ppsuxr.p'
    &PARAM="(input pod_part,
    input pod_vpart,
    input po_vend,
    output mfgr_part,
    output mfgr,
    output dummy_um)"
    &NOAPPERROR=true
    &CATCHERROR=true}

assign
    pod-project = pod_project
    pod-type    = pod_type
    global_site = pod_site
    global_addr = po_vend
    old_fix_pr  = pod_fix_pr.

setd:
do on error undo, retry:
    if global-beam-me-up then undo, leave.
    /* DO NOT RETRY WHEN PROCESSING API REQUEST */
    if retry and c-application-mode = "API" then
        undo setd, return error.

    /* fdn */ pod_status = new_pod_status.

    /* VALIDATES PO LINE REVISION */
    {pxrun.i &PROC='validatePOLineRevision' &PROGRAM='popoxr1.p'
        &PARAM="(input pod_rev)"
        &NOAPPERROR=true
        &CATCHERROR=true
    }

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    /* VALIDATES PO LINE STATUS */
    {pxrun.i &PROC='validatePOLineStatus' &PROGRAM='popoxr1.p'
        &PARAM="(input pod_status)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    /* CHECKS FOR FIELD-LEVEL ACCESS ON PO LINE FIXED PRICE FLAG */
    if pod_fix_pr <> old_fix_pr then do:
        {pxrun.i &PROC='validatePOLineFixedPrice' &PROGRAM='popoxr1.p'
            &PARAM="(input pod_fix_pr)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        if return-value <> {&SUCCESS-RESULT} then do:
            undo setd, return error.
        end.
    end. /* IF pod_fix_pr <> old_fix_pr */

    if pod_type <> "B" then do:
        {pxrun.i &PROC='validatePOLineType' &PROGRAM='popoxr1.p'
            &PARAM="(input pod_type)"
            &NOAPPERROR=true
            &CATCHERROR=true}
    end.

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    /* VALIDATES PO LINE UOM CONVERSION */
    {pxrun.i &PROC='validatePOLineUMConv' &PROGRAM='popoxr1.p'
        &PARAM="(input pod_um_conv)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    {pxrun.i &PROC='validateShipperExists' &PROGRAM='popoxr.p'
        &PARAM="(input pod_status,
        input pod_nbr,
        input pod_site,
        input pod_line)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value = {&APP-ERROR-RESULT} then do:
        undo setd, return error.
    end.

    {pxrun.i &PROC='validatePRMProject' &PROGRAM='pjprmxr.p'
        &PARAM="(input pod-project,
        input input pod_project,
        input pod_pjs_line)"
        &NOAPPERROR=true
        &CATCHERROR=true}
        
    if return-value <> {&SUCCESS-RESULT}then do:
        undo setd, return error.
    end.

    {pxrun.i &PROC='validatePRMType' &PROGRAM='pjprmxr.p'
        &PARAM="(input pod_type,
        input pod-type,
        input pod_pjs_line)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    prm-project = can-find(prj_mstr where prj_nbr = input pod_project).

    if (prm-enabled and prm-project and sngl_ln and pod_det.pod_qty_rcvd = 0 and pod_det.pod_type <> "S"
        and (not blanket)) or (prm-enabled and sngl_ln and (not blanket) and pod_det.pod_pjs_line <> 0) then do:
        /* UPDATE PO PROJECT LINE */
        {gprunmo.i
            &program = ""pjpomtd.p""
            &module  = "PRM"
            &param   = """(buffer pod_det)"""}
    end. /*IF PRM-ENABLED AND NOT BLANKET */

    /* VALIDATES PO LINE TAX CLASS */
    {pxrun.i &PROC='validateTaxClass' &PROGRAM='txenvxr.p'
        &PARAM="(input pod_taxc)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    if pod_taxable then do:
        {pxrun.i &PROC='validateSiteChanged' &PROGRAM='popoxr1.p'
            &PARAM="(input pod_site,
            input old_pod_site)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        if return-value <> {&SUCCESS-RESULT} then
            pod_tax_env = "".

        taxloop:
        do on error undo, retry:

            if global-beam-me-up then undo, leave.
            if retry and c-application-mode = "API" then 
                undo taxloop, return error.

            if pod_tax_env = "" then do:
                {pxrun.i &PROC='getTaxEnvironment' &PROGRAM='popoxr.p'
                    &PARAM="(input  vd_addr,
                    input  pod_site,
                    input  '',
                    input po_taxc,
                    output pod_tax_env)"
                    &NOAPPERROR=true
                    &CATCHERROR=true}
            end. /* IF pod_tax_env = "" */

            /* VALIDATES PO LINE TAX USAGE */
            {pxrun.i &PROC='validateTaxUsage'
                &PROGRAM='txenvxr.p'
                &PARAM="(input pod_tax_usage)"
                &NOAPPERROR=true
                &CATCHERROR=true}

            if return-value <> {&SUCCESS-RESULT} then do:
                undo taxloop, return error.
            end.

            /* VALIDATES PO LINE TAX ENVIRONMENT */
            {pxrun.i &PROC='validateTaxEnvironment' &PROGRAM='txenvxr.p'
                &PARAM="(input pod_tax_env)"
                &NOAPPERROR=true
                &CATCHERROR=true}

            if return-value <> {&SUCCESS-RESULT} then do:
                undo taxloop, return error.
            end.

            if c-application-mode <> "API" then hide frame set_tax.
            {&POPOMTD-P-TAG2}
        end.
        if global-beam-me-up then undo, leave.
        /* TAXLOOP */
    end.  /* IF pod_taxable */

    if pod_per_date = ? then
        pod_per_date = pod_due_date.

    if pod_need = ? then
        pod_need = pod_due_date.

    if can-find (first vp_mstr where vp_mstr.vp_part >= "" and vp_mstr.vp_vend >= ""
        and vp_mstr.vp_vend_part >= "") then do:
        /* GETS MANUFACTURER AND MANUFACTURER ITEM FOR A SUPPLIER ITEM */
        {pxrun.i &PROC='getManufacturerItemData' &PROGRAM='ppsuxr.p'
            &PARAM="(input pod_part,
            input pod_vpart,
            input po_vend,
            output mfgr_part,
            output mfgr,
            output dummy_um)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        /* READS SUPPLIER ITEM MASTER */
        {pxrun.i &PROC='processRead' &PROGRAM='ppsuxr.p'
            &PARAM="(input pod_part,
            input po_vend,
            input pod_vpart,
            buffer vp_mstr,
            {&NO_LOCK_FLAG},
            {&NO_WAIT_FLAG})"
            &NOAPPERROR=true
            &CATCHERROR=true}

        if return-value = {&SUCCESS-RESULT} then do:
            if (new pod_det or pod_pur_cost <> old_pur_cost or pod_vpart <> old_vpart) then do:
                if vp_q_price <> pod_pur_cost and vp_um = pod_um and po_curr = vp_curr and pod_qty_ord >= vp_q_qty then do:
                    /* UPDATE PO LINE UNIT COST WITH SUPPLIER ITEM QUOTE COST */
                    {pxrun.i &PROC='setQuoteCost' &PROGRAM='ppsuxr.p'
                        &PROGRAM='ppsuxr.p'
                        &PARAM="(input pod_vpart,
                        input pod_part,
                        input po_vend,
                        input pod_pur_cost)"
                        &NOAPPERROR=true
                        &CATCHERROR=true}
                end.  /* IF vp_q_price <> pod_pur_cost AND ... */
            end.  /* IF (NEW pod_det OR ...*/
        end.  /* IF RETURN-VALUE = {&SUCCESS-RESULT} */
    end.  /* IF can-find (FIRST vp_mstr where ... */

    /* VALIDATES CHANGE IN PO LINE STATUS */
    {pxrun.i &PROC='validatePOLineStatusChanged' &PROGRAM='popoxr1.p'
        &PARAM="(input pod_status,
        input old_pod_status)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if ({pxfunct.i &FUNCTION='isOpenLineOnClosedPO' &PROGRAM='popoxr1.p'
        &PARAM="input po_stat,
        input pod_status"}) then do:
        /* RE-OPENS A CLOSED PURCHASE ORDER */
        {pxrun.i &PROC='reOpenPurchaseOrder' &PROGRAM='popoxr.p'
            &PARAM="(input pod_nbr)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        line_opened = true.
    end.  /* IF ({pxfunct.i &FUNCTION='isOpenLineOnClosedPO' ...*/

    /* CLOSES A REQUISITION LINE FOR MANUALLY CLOSED PO LINE */
    {pxrun.i &PROC='closeRequisition' &PROGRAM='rqgrsxr.p'
        &PARAM="(input pod_status,
        input pod_req_nbr,
        input pod_req_line,
        input no)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    /* VALIDATES SUBCONTRACT TYPE PO LINE */
    {pxrun.i &PROC='validateSubcontractItem' &PROGRAM='popoxr1.p'
        &PARAM="(input pod_qty_ord,
        input pod_part,
        input pod_type)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    /* VALIDATES BLANKET ORDER RELEASE QUANTITY */
    {pxrun.i &PROC='validateBlanketRelQty' &PROGRAM='popoxr1.p'
        &PARAM="(input blanket,
        buffer pod_det)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    /* VALIDATES BLANKET TYPE PO LINE */
    {pxrun.i &PROC='validateForBlanketType' &PROGRAM='popoxr1.p'
        &PARAM="(input blanket,
        input pod_type)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    if not using_grs then do:
        /* VALIDATES TYPE FOR PO LINE WITH REQUISITION */
        {pxrun.i &PROC='validatePOLineTypeForRequisition' &PROGRAM='popoxr1.p'
            &PARAM="(input Blanket,
            input pod_req_nbr,
            input pod_part,
            input pod_type)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        if return-value <> {&SUCCESS-RESULT} then do:
            undo setd, return error.
        end.
    end.  /* IF NOT USING_GRS */

    /* VALIDATES PO LINE ACCOUNT/SUB-ACCT/COST CENTER AND PROJECT */
    {pxrun.i &PROC='validateFullAccount' &PROGRAM='glacxr.p'
        &PARAM="(input pod_acct,
        input  pod_sub,
        input  pod_cc,
        input pod_project)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if return-value <> {&SUCCESS-RESULT} then do:
        undo setd, return error.
    end.

    /* UPDATES PO LINE ITEM DESCRIPTION */
    {pxrun.i &PROC='setPOItemDescription' &PROGRAM='popoxr1.p'
        &PARAM="(input pod_part,
        input-output pod_desc,
        input desc1)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if pod_um_conv <> old_um_conv then do:
        /* GETS STOCK QUANTITY AFTER APPLY CONVERSION FACTOR ON UNIT COST */
        st_qty = pod_qty_ord.
        {pxrun.i &PROC='convertFromPoToInventoryUm' &PROGRAM='popoxr1.p'
            &PARAM="(input-output st_qty,
            input pod_um_conv)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        if  using_grs and pod_req_nbr <> "" then do:

            {pxrun.i &PROC='updateRequisitionCrossReference'
                &PROGRAM='rqgrsxr1.p'
                &PARAM="(input pod_site,
                input pod_req_nbr,
                input pod_req_line,
                input pod_nbr,
                input pod_line,
                input pod_qty_ord,
                input pod_um,
                output requm,
                output ok)" &NOAPPERROR=True &CATCHERROR=True}

            {pxrun.i &PROC='updateMRPForRequisition' &PROGRAM='rqgrsxr1.p'
                &PARAM="(input pod_site,
                input pod_req_nbr,
                input pod_req_line)"
                &NOAPPERROR=True &CATCHERROR=True}
        end. /* IF using_grs ... */
    end.

    /* UPDATES PO LINE LOCATION BASED INSPECTION REQUIRED FLAG */
    {pxrun.i &PROC='updatePOLineLocationForInspection' &PROGRAM='popoxr1.p'
        &PARAM="(input pod_insp_rqd,
        input poc_insp_loc,
        input-output pod_loc)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    {pxrun.i &PROC='setSubcontractType' &PROGRAM='popoxr1.p'
        &PARAM="(buffer pod_det)"
        &NOAPPERROR=true
        &CATCHERROR=true}

    if pod_type = "S" and (pod_req_nbr = "" or not can-find(first req_det where req_nbr = pod_req_nbr)) then do:
        old_db = global_db.
        if si_db <> global_db then
            {gprun.i ""gpalias3.p"" "(si_db, output err-flag)" }
        if global-beam-me-up then undo, leave.
        assign
            worklot  = pod_wo_lot
            routeop  = pod_op
            workpart = pod_part
            subtype  = pod__qad16
            workproj = pod_project.

        if subtype = ? then subtype = "".

        /* PO MAINTENANCE VALIDATE REMOTE DB WORK ORDERS */
        {gprun.i ""popomtd1.p""}
        if global-beam-me-up then undo, leave.

        assign
            pod_wo_lot = worklot
            pod__qad16 = subtype
            pod_op     = routeop.

        if old_db <> global_db then
            {gprun.i ""gpalias3.p"" "(old_db, output err-flag)" }

        if global-beam-me-up then undo, leave.
    end.

    /* VALIDATE POD_SITE'S PT_MSTR WHEN PO_LINE HAD BEEN MEMO */
    if (pod_type = "") and (old_type = "M") then do:

        /* CHECKS FOR ITEM ON NON CENTRAL DATABASE */
        {pxrun.i &PROC='validateItemOnRemoteDB' &PROGRAM='popoxr1.p'
            &PARAM="(input pod_part,
            input pod_site)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        if return-value <> {&SUCCESS-RESULT} then do:
            assign
                pod_type = old_type
                err-flag = 0.

            undo setd, return error.
        end.
    end.
end.
if global-beam-me-up then undo, leave.
/* Setd */

/* ERS PROCESSING BLOCK */
if poc_ers_proc = yes then do:

    /* UPDATE ERS FIELDS */
    looper:
    do on error undo looper, retry looper with frame ers:
        if global-beam-me-up then undo, leave.
        if retry and c-application-mode = "API" then undo looper, return error.
        old_ers_opt = pod_ers_opt.

        if pod_ers_opt <> old_ers_opt then do:
            /* CHECKS FOR FIELD-LEVEL ACCESS ON PO LINE ERS OPTION */
            {pxrun.i &PROC='validatePOLineERSOptSecurity' &PROGRAM='popoxr1.p'
                &PARAM="(input pod_ers_opt)"
                &NOAPPERROR=true
                &CATCHERROR=true}

            if return-value <> {&SUCCESS-RESULT} then do:
                undo looper, return error.
            end.
        end.

        /* VALIDATES PO LINE ERS PRICE LIST OPTION */
        {pxrun.i &PROC='validatePOLineERSPriceListOpt' &PROGRAM='popoxr1.p'
            &PARAM="(input pod_pr_lst_tp)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        if return-value <> {&SUCCESS-RESULT} then do:
            undo looper, return error.
        end.

        /* VALIDATES PO LINE ERS OPTION */
        {pxrun.i &PROC='validatePOLineERSOption' &PROGRAM='popoxr1.p'
            &PARAM="(input pod_ers_opt)"
            &NOAPPERROR=true
            &CATCHERROR=true}

        if return-value <> {&SUCCESS-RESULT} then do:
            undo looper, return error.
        end.
    end.
    if global-beam-me-up then undo, leave.
    /*LOOPER*/
    if c-application-mode <> "API" then hide frame ers.
end. /*IF POC_ERS_PROC = YES*/


if using_supplier_consignment and can-find(pt_mstr where pt_part = pod_part) then do:
    if new pod_det then do:
        {pxrun.i &PROC = 'initializeSuppConsignDetailFields'
            &PARAM="(input po_vend,
            input pod_part,
            input po_consignment,
            input po_max_aging_days,
            output pod_consignment,
            output pod_max_aging_days)"}
    end.  /* if new pod_det */

    if c-application-mode <> "API" then do:

        /* Set maximum aging days */
        if pod_consignment then do:
            {pxrun.i &PROC='setAgingDays'
                &PARAM="(input-output pod_max_aging_days)"}
            hide frame aging.
        end.
    end.  /* If c-application-mode <> "API" */
end.

/* Set the flag to yes for successful completion */
continue = yes.
